package com.tyk.bookstore.back.product.model.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.tyk.bookstore.back.common.core.util.FileUtil;
import com.tyk.bookstore.back.product.model.enume.BookState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description 书籍
 */
@Data
@Schema(name = "BookVo", description = "书籍")
public class BookVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "ID")
    private Long id;

    @Schema(description = "书籍编号")
    private String bookNo;

    @Schema(description = "书名")
    private String name;

    @Schema(description = "价格")
    private BigDecimal price;

    @Schema(description = "封面路径")
    private String cover;

    @Schema(description = "标题")
    private String title;

    @Schema(description = "书籍简介")
    private String summary;

    @Schema(description = "作者ID")
    @TableField("author_id")
    private Long authorId;

    @Schema(description = "作者名称")
    private String authorName;

    @Schema(description = "出版社ID")
    @TableField("publisher_id")
    private Long publisherId;

    @Schema(description = "出版社名称")
    private String publisherName;

    @Schema(description = "出版时间")
    private LocalDateTime publishTime;

    @Schema(description = "ISBN")
    private String isbn;

    @Schema(description = "各级分类")
    private List<ClazzNameVo> clazzList;

    @Schema(description = "字数[单位：万字]")
    private BigDecimal wordNum;

    @Schema(description = "重量[单位：克]")
    private Long weight;

    @Schema(description = "规格")
    private Integer format;

    @Schema(description = "状态[0下架，1上架]")
    private BookState state;

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "书籍展示图片")
    private List<String> imgList;

    @Schema(description = "销量")
    private Long saleNum;

    @Schema(description = "付款人数")
    private Long payNum;

    @Schema(description = "评论人数")
    private Long commentNum;

    @Schema(description = "收藏人数")
    private Long collectNum;

    @Schema(description = "点赞人数")
    private Long likeNum;

    public BookVo setCover(String cover) {
        this.cover = FileUtil.fullFilePath(cover);
        return this;
    }

    @Data
    public static class ClazzNameVo {
        @Schema(description = "分类ID")
        private Long clazzId;
        @Schema(description = "分类名称")
        private String clazzName;
    }

}
